<?php

class PeopleController extends CoreController
{
    public $uid;
    public $role;
    public $role_salt;
    public function init(){
        $this->uid = Yii::app()->user->id;
        $this->role = Yii::app()->user->getState('user_role');
        $this->role_salt = Yii::app()->user->getState('role_salt');
    }

    public function actionReindex(){
        if(Yii::app()->request->isAjaxRequest){
            $tbl_id = intval(Yii::app()->request->getParam('tbl_id'));
            $exceed_time = time() + Yii::app()->params['EXCEED_TIME'];
            $tbl_name = Yii::app()->request->getParam('tbl_name');
            $sction_code = Yii::app()->request->getParam('sction_code');
            //写入section_recommend表 $section_code,$tbl_name,$tbl_id,$exceed_time
            $ok = SectionRecommend::model()->createData($sction_code,$tbl_name,$tbl_id,$exceed_time);
            if($ok){
                $data['status'] = 1;
                $data['message'] = '推送成功';
            }else{
                $data['status'] = 0;
                $data['message'] = '推送失败';
            }
            echo json_encode($data);
            Yii::app()->end();
        }else{
            Xtutuquan::redirect_message('非法操作','error',2);
        }
    }
    public function actionRecommend(){
        if(Yii::app()->request->isAjaxRequest){
            $uid = intval(Yii::app()->request->getParam('uid'));
            $ok = User::model()->recommendUser($uid);
            if($ok){
                $data['status'] = 1;
                $data['message'] = '推荐成功';
            }else{
                $data['status'] = 0;
                $data['message'] = '推荐失败';
            }
            echo json_encode($data);
            Yii::app()->end();
        }else{
            Xtutuquan::redirect_message('非法操作','error',2);
        }
    }
}